package com.sskj.aikeeper.presenter;

import com.hjq.toast.ToastUtils;
import com.lzy.okgo.model.Response;
import com.sskj.aikeeper.R;
import com.sskj.aikeeper.hangqing.activity.ChangePayActivity;
import com.sskj.common.base.App;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.MD5Util;
import com.sskj.lib.BaseHttpConfig;
import com.sskj.lib.http.JsonCallBack;


/**
 * @author Hey
 * Create at  2019/06/25
 */
public class ChangePayPresenter extends BasePresenter<ChangePayActivity> {

    public void getRegisterCode(String number) {
        httpService.getCode(number, "4")
                .tag(this)
                .execute(new JsonCallBack<HttpData>() {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        ToastUtils.show(response.body().getMsg());
                        if (response.body().status == BaseHttpConfig.OK) {
                            mView.sendOK();
                        }
                    }
                });
    }

    public void changePayPwd(String mobile, String tpwd, String tpwd1, String code) {
        httpService.changePayPwd(mobile, MD5Util.getFiveMd5Value(tpwd), MD5Util.getFiveMd5Value(tpwd1), code)
                .tag(this)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        if (response.body().status == BaseHttpConfig.OK) {
                            ToastUtils.show(App.INSTANCE.getString(R.string.app_changeLoginPresenter1));
                            mView.finish();
                        }
                    }
                });
    }
}
